package com.keon.jianbao.api;

import com.keon.jianbao.AppContext;
import com.keon.jianbao.util.ConstantUtils;
import com.loopj.android.http.AsyncHttpResponseHandler;

/**
 * Created by keon on 15/10/25.
 */
public class WXApi {
    public static void getWXAccessToken(String code, AsyncHttpResponseHandler handler) {
        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + ConstantUtils.WX_APP_ID + "&secret=" + ConstantUtils.WX_APP_SECRET + "&code=" + code + "&grant_type=authorization_code";
        ApiHttpClient.g(url, handler);
    }

    public static void WXUserinfo(String accessToken, String openid, AsyncHttpResponseHandler handler) {
        String url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + accessToken + "&openid=" + openid;
        ApiHttpClient.g(url, handler);
    }

    public static void refresh_token(AsyncHttpResponseHandler handler) {
        String refresh_token = AppContext.getInstance().getProperty("wx.refresh_token");
        String url = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=" + ConstantUtils.WX_APP_ID + "&grant_type=refresh_token&refresh_token=" + refresh_token;
        ApiHttpClient.g(url, handler);
    }


}
